﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace Northwind
{
    class ProductsInfo
    {
        public static void GetProductsInfo()
        {
            string sqlQuery =
@"SELECT ProductName, CategoryName
FROM Products p JOIN Categories c ON p.CategoryID = c.CategoryID";
            using (SqlConnection connection = new SqlConnection(@"Server=.\SQLEXPRESS;Database=Northwind;Integrated Security=true"))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(sqlQuery, connection);
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    string productName = (string)reader["ProductName"];
                    string categoryName = (string)reader["CategoryName"];
                    Console.WriteLine("{0} {1}", productName, categoryName);
                }
            }
        }
    }
}
